/*
 * Copyright (c) zhg2yqq.com Corp.
 * All Rights Reserved.
 */

package com.zhg2yqq.wheels.devops;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
import org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryCustomizer;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import io.micrometer.core.instrument.MeterRegistry;

@Configuration
@EnableConfigurationProperties(WebEndpointProperties.class)
public class ActuatorConfiguration {
//    @Bean
//    FilterRegistrationBean registFilter(WebEndpointProperties endpoint) {
//        FilterRegistrationBean registration = new FilterRegistrationBean();
//        registration.setFilter(new javax.servlet.Filter() {
//            @Override
//            public void init(FilterConfig filterConfig) throws ServletException {
//                Filter.super.init(filterConfig);
//            }
//
//            @Override
//            public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
//                servletRequest.
//            }
//        });
//        registration.addUrlPatterns(endpoint.getBasePath() + "/*");
//        registration.setName("actuatorFilter");
//        registration.setOrder(1);
//        return registration;
//    }

    @Bean
    public MeterRegistryCustomizer<MeterRegistry> configurer(@Value("${spring.application.name}") String applicationName) {
        return (registry) -> registry.config().commonTags("application", applicationName);
    }
}
